<!DOCTYPE html>
<html class="ui-page-login">

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="./css/mui.min.css" rel="stylesheet" />
		<link href="./css/setting.css" rel="stylesheet">
		<link href="./css/form2.css" rel="stylesheet">
		<style>
			.area {
				margin: 20px auto 0px auto;
			}
			
			.mui-input-group:first-child {
				margin-top: 20px;
			}
			
			.mui-input-group label {
				width: 22%;
			}
			
			.mui-input-row label~input,
			.mui-input-row label~select,
			.mui-input-row label~textarea {
				width: 78%;
			}
			
			.mui-checkbox input[type=checkbox],
			.mui-radio input[type=radio] {
				top: 6px;
			}
			
			.mui-content-padded {
				margin-top: 25px;
			}
			
			.mui-btn {
				padding: 10px;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">密码重置</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group">
				<div class="mui-input-row">
					<label style="font-size: 16px;">新密码</label>
					<input id='password' type="password" class="mui-input-clear mui-input" placeholder="请输入密码">
				</div>
				<div class="mui-input-row">
					<label style="font-size: 16px;">确认</label>
					<input id='password_confirm' type="password" class="mui-input-clear mui-input" placeholder="请输入确认密码">
				</div>
			</form>
			<div class="mui-button-row">
				<button id='reg' class="mui-btn mui-btn-warning bgcolor mui-pull-center" style="width: 100%;" onclick="resetPassword()">提交</button>
			</div>
		</div>
		<script src="./js/mui.js"></script>
		<script src="./js/jquery-1.10.2.min.js"></script>
		<script src="./js/common.js"></script>
		<script src="./js/vue.min.js"></script>
		<script>
			mui.init({
				swipeBack: true //启用右滑关闭功能
			});

			function resetPassword() {
				var passwordConfirm = $("#password_confirm").val();
				var password = $("#password").val();
				if(isNull(password)){
					mui.toast('请输入密码');
					return;
				}
				if(isNull(passwordConfirm)){
					mui.toast('请输入确认密码');
					return;
				}
				if(passwordConfirm != password) {
					mui.toast('密码两次输入不一致');
					return;
				}
				var url = root + "myCenter/resetPassword";
				mui.post(url, {mobile:$.getUrlParam('mobile'),password:password},
					function(data) {
						var status = data.status;
						if(status == "success") {
							var btnArray = ['确认', '取消'];
						    mui.confirm('密码修改成功，请重新登录', '', btnArray, function(e) {
						        if (e.index == 1) {
						            mui.openWindow("index.html", '', {});
						        } else {
						            mui.openWindow("login.html", '', {});
						        }
						    });
						}
						if(status == "failed") {
							mui.alert(data.msg);
						}
					}, 'json'
				);
			}
		</script>
	</body>

</html>